/**
 * @产生质数表
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>
#define COUNT 100

int main(int argc, char *argv[]) {
	//p是质数
	int p, i, primes[COUNT], index=2;
	bool s;
	
	//将数组的第一个元素和第二个元素分别赋值
	primes[0] = 2;
	primes[1] = 3;

	//质数在5~规定的数之间，真正执行
	for (p=5; p<=COUNT; p = p + 2) {
		s = true;
		
		//下面的条件是什么意思？
		for (i=1; s && p / primes[i] >= primes[i]; i++) {
			if (p % primes[i] == 0) {
				s = false;
			}
		}

		if (s == true) {
			primes[index] = p;
			index++;
		}
	}

	for (i=0; i<index; i++) {
		printf("%d\n", primes[i]);
	}

	printf("\n");

	return 0;
}
